import 'package:flutter/material.dart';

import '../net_file_data.dart';

/// attatchIds : "[4760515434737664, 4770458824847360]"
/// bedNo : "102-7"
/// branchId : 6627
/// buildingId : 74
/// buildingNo : "22号楼"
/// createdBy : "8952"
/// createdByName : "护理员小陈"
/// createdDate : "2023-12-15 14:40:49"
/// deleteStatus : 0
/// elderId : 7644
/// elderName : "曾三妹"
/// eventProcess : "yyyyyyyyyyyyyyyyy"
/// eventStatus : 4
/// eventType : 1
/// eventTypeName : "跌倒事件"
/// followList : [{"attatchIds":"[4760515434737664, 4770458824847360]","branchId":6627,"createdBy":"8952","createdDate":"2023-12-15 14:47:25","deleteStatus":0,"detail":"xxxxxx","emergencyEventManageId":4780191922745344,"endFollow":false,"handleTime":"2023-12-15 00:00:00","id":4780198230372352,"saasId":1000,"tenantId":1000,"updatedBy":"8952","updatedDate":"2023-12-15 14:47:25"},{"attatchIds":"[4760515434737664, 4770458824847360]","branchId":6627,"createdBy":"8952","createdDate":"2023-12-15 14:46:56","deleteStatus":0,"detail":"xxxxxx","emergencyEventManageId":4780191922745344,"endFollow":false,"handleTime":"2023-12-15 00:00:00","id":4780197764231168,"saasId":1000,"tenantId":1000,"updatedBy":"8952","updatedDate":"2023-12-15 14:46:56"}]
/// handleList : [{"attatchIds":"[4760515434737664, 4770458824847360]","branchId":6627,"createdBy":"8952","createdDate":"2023-12-15 14:45:42","deleteStatus":0,"detail":"xxxxxx","emergencyEventManageId":4780191922745344,"handleTime":"2023-12-15 00:00:00","id":4780196538396672,"saasId":1000,"tenantId":1000,"updatedBy":"8952","updatedDate":"2023-12-15 14:45:42"}]
/// id : 4780191922745344
/// occurrencePlace : 74
/// occurrencePlaceName : "22号楼"
/// occurrenceTime : "2023-12-15 00:00:00"
/// oldManNumber : null
/// placeDetail : "xxxxxxxxxxxxx"
/// reflectList : [{"branchId":6627,"createdBy":"8952","createdDate":"2023-12-15 14:48:41","deleteStatus":0,"detail":"xxxxxx","emergencyEventManageId":4780191922745344,"id":4780199476064256,"saasId":1000,"tenantId":1000,"updatedBy":"8952","updatedDate":"2023-12-15 14:48:41"}]
/// roomNo : "102"
/// saasId : 1000
/// tenantId : 1000
/// updatedBy : "8952"
/// updatedDate : "2023-12-15 14:48:41"

class EventManageListData {
  EventManageListData(
      {this.attatchIds,
      this.bedNo,
      this.branchId,
      this.buildingId,
      this.buildingNo,
      this.createdBy,
      this.createdByName,
      this.createdDate,
      this.deleteStatus,
      this.elderId,
      this.elderName,
      this.eventProcess,
      this.eventStatus,
      this.eventType,
      this.eventTypeName,
      this.followList,
      this.handleList,
      this.id,
      this.occurrencePlace,
      this.occurrencePlaceName,
      this.occurrenceTime,
      this.oldManNumber,
      this.placeDetail,
      this.reflectList,
      this.roomNo,
      this.saasId,
      this.tenantId,
      this.updatedBy,
      this.updatedDate,
      this.commonAttaches});

  EventManageListData.fromJson(dynamic json) {
    attatchIds = json['attatchIds'];
    bedNo = json['bedNo'];
    branchId = json['branchId'];
    buildingId = json['buildingId'];
    buildingNo = json['buildingNo'];
    createdBy = json['createdBy'];
    createdByName = json['createdByName'];
    createdDate = json['createdDate'];
    deleteStatus = json['deleteStatus'];
    elderId = json['elderId'];
    elderName = json['elderName'];
    eventProcess = json['eventProcess'];
    eventStatus = json['eventStatus'];
    eventType = json['eventType'];
    eventTypeName = json['eventTypeName'];
    commonAttaches = ((json['commonAttaches'] as List?) ?? [])
        .map((e) => NetFileData.fromJson(e))
        .toList();
    if (json['followList'] != null) {
      followList = [];
      json['followList'].forEach((v) {
        followList?.add(EventFollowList.fromJson(v));
      });
    }
    if (json['handleList'] != null) {
      handleList = [];
      json['handleList'].forEach((v) {
        handleList?.add(EventHandleList.fromJson(v));
      });
    }
    id = json['id'];
    occurrencePlace = json['occurrencePlace'];
    occurrencePlaceName = json['occurrencePlaceName'];
    occurrenceTime = json['occurrenceTime'];
    oldManNumber = json['oldManNumber'];
    placeDetail = json['placeDetail'];
    if (json['reflectList'] != null) {
      reflectList = [];
      json['reflectList'].forEach((v) {
        reflectList?.add(ReflectList.fromJson(v));
      });
    }
    roomNo = json['roomNo'];
    saasId = json['saasId'];
    tenantId = json['tenantId'];
    updatedBy = json['updatedBy'];
    updatedDate = json['updatedDate'];
  }

  String? attatchIds;
  String? bedNo;
  num? branchId;
  num? buildingId;
  String? buildingNo;
  String? createdBy;
  String? createdByName;
  String? createdDate;
  num? deleteStatus;
  num? elderId;
  String? elderName;
  String? eventProcess;
  num? eventStatus;
  num? eventType;
  String? eventTypeName;
  List<EventFollowList>? followList;
  List<EventHandleList>? handleList;
  num? id;
  num? occurrencePlace;
  String? occurrencePlaceName;
  String? occurrenceTime;
  dynamic oldManNumber;
  String? placeDetail;
  List<ReflectList>? reflectList;
  String? roomNo;
  num? saasId;
  num? tenantId;
  String? updatedBy;
  String? updatedDate;
  List<NetFileData>? commonAttaches;

  EventManageListData copyWith({
    String? attatchIds,
    String? bedNo,
    num? branchId,
    num? buildingId,
    String? buildingNo,
    String? createdBy,
    String? createdByName,
    String? createdDate,
    num? deleteStatus,
    num? elderId,
    String? elderName,
    String? eventProcess,
    num? eventStatus,
    num? eventType,
    String? eventTypeName,
    List<EventFollowList>? followList,
    List<EventHandleList>? handleList,
    num? id,
    num? occurrencePlace,
    String? occurrencePlaceName,
    String? occurrenceTime,
    dynamic oldManNumber,
    String? placeDetail,
    List<ReflectList>? reflectList,
    String? roomNo,
    num? saasId,
    num? tenantId,
    String? updatedBy,
    String? updatedDate,
  }) =>
      EventManageListData(
        attatchIds: attatchIds ?? this.attatchIds,
        bedNo: bedNo ?? this.bedNo,
        branchId: branchId ?? this.branchId,
        buildingId: buildingId ?? this.buildingId,
        buildingNo: buildingNo ?? this.buildingNo,
        createdBy: createdBy ?? this.createdBy,
        createdByName: createdByName ?? this.createdByName,
        createdDate: createdDate ?? this.createdDate,
        deleteStatus: deleteStatus ?? this.deleteStatus,
        elderId: elderId ?? this.elderId,
        elderName: elderName ?? this.elderName,
        eventProcess: eventProcess ?? this.eventProcess,
        eventStatus: eventStatus ?? this.eventStatus,
        eventType: eventType ?? this.eventType,
        eventTypeName: eventTypeName ?? this.eventTypeName,
        followList: followList ?? this.followList,
        handleList: handleList ?? this.handleList,
        id: id ?? this.id,
        occurrencePlace: occurrencePlace ?? this.occurrencePlace,
        occurrencePlaceName: occurrencePlaceName ?? this.occurrencePlaceName,
        occurrenceTime: occurrenceTime ?? this.occurrenceTime,
        oldManNumber: oldManNumber ?? this.oldManNumber,
        placeDetail: placeDetail ?? this.placeDetail,
        reflectList: reflectList ?? this.reflectList,
        roomNo: roomNo ?? this.roomNo,
        saasId: saasId ?? this.saasId,
        tenantId: tenantId ?? this.tenantId,
        updatedBy: updatedBy ?? this.updatedBy,
        updatedDate: updatedDate ?? this.updatedDate,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['attatchIds'] = attatchIds;
    map['bedNo'] = bedNo;
    map['branchId'] = branchId;
    map['buildingId'] = buildingId;
    map['buildingNo'] = buildingNo;
    map['createdBy'] = createdBy;
    map['createdByName'] = createdByName;
    map['createdDate'] = createdDate;
    map['deleteStatus'] = deleteStatus;
    map['elderId'] = elderId;
    map['elderName'] = elderName;
    map['eventProcess'] = eventProcess;
    map['eventStatus'] = eventStatus;
    map['eventType'] = eventType;
    map['eventTypeName'] = eventTypeName;
    if (followList != null) {
      map['followList'] = followList?.map((v) => v.toJson()).toList();
    }
    if (handleList != null) {
      map['handleList'] = handleList?.map((v) => v.toJson()).toList();
    }
    map['commonAttaches'] = commonAttaches?.map((e) => e.toJson()).toList();
    map['id'] = id;
    map['occurrencePlace'] = occurrencePlace;
    map['occurrencePlaceName'] = occurrencePlaceName;
    map['occurrenceTime'] = occurrenceTime;
    map['oldManNumber'] = oldManNumber;
    map['placeDetail'] = placeDetail;
    if (reflectList != null) {
      map['reflectList'] = reflectList?.map((v) => v.toJson()).toList();
    }
    map['roomNo'] = roomNo;
    map['saasId'] = saasId;
    map['tenantId'] = tenantId;
    map['updatedBy'] = updatedBy;
    map['updatedDate'] = updatedDate;
    return map;
  }

  bool get canHandle => eventStatus == 0;

  bool get canFollow => eventStatus == 1 || eventStatus == 2;

  Color get titleColor {
    ///待处理
    if (eventStatus == 0) {
      return Colors.red;
    }
    if (eventStatus == 1 || eventStatus == 2) {
      return Colors.yellow[700]!;
    }
    if (eventStatus == 3) {
      return Colors.green;
    }
    return Colors.green;
  }
}

/// branchId : 6627
/// createdBy : "8952"
/// createdDate : "2023-12-15 14:48:41"
/// deleteStatus : 0
/// detail : "xxxxxx"
/// emergencyEventManageId : 4780191922745344
/// id : 4780199476064256
/// saasId : 1000
/// tenantId : 1000
/// updatedBy : "8952"
/// updatedDate : "2023-12-15 14:48:41"

class ReflectList {
  ReflectList({
    this.branchId,
    this.createdBy,
    this.createdDate,
    this.deleteStatus,
    this.detail,
    this.emergencyEventManageId,
    this.id,
    this.saasId,
    this.tenantId,
    this.updatedBy,
    this.updatedDate,
  });

  ReflectList.fromJson(dynamic json) {
    branchId = json['branchId'];
    createdBy = json['createdBy'];
    createdDate = json['createdDate'];
    deleteStatus = json['deleteStatus'];
    detail = json['detail'];
    emergencyEventManageId = json['emergencyEventManageId'];
    commonAttaches = ((json['commonAttaches'] as List) ?? [])
        .map((e) => NetFileData.fromJson(e))
        .toList();
    id = json['id'];
    saasId = json['saasId'];
    tenantId = json['tenantId'];
    updatedBy = json['updatedBy'];
    updatedDate = json['updatedDate'];
  }

  num? branchId;
  String? createdBy;
  String? createdDate;
  num? deleteStatus;
  String? detail;
  num? emergencyEventManageId;
  num? id;
  num? saasId;
  num? tenantId;
  String? updatedBy;
  String? updatedDate;
  List<NetFileData>? commonAttaches;

  ReflectList copyWith({
    num? branchId,
    String? createdBy,
    String? createdDate,
    num? deleteStatus,
    String? detail,
    num? emergencyEventManageId,
    num? id,
    num? saasId,
    num? tenantId,
    String? updatedBy,
    String? updatedDate,
  }) =>
      ReflectList(
        branchId: branchId ?? this.branchId,
        createdBy: createdBy ?? this.createdBy,
        createdDate: createdDate ?? this.createdDate,
        deleteStatus: deleteStatus ?? this.deleteStatus,
        detail: detail ?? this.detail,
        emergencyEventManageId:
            emergencyEventManageId ?? this.emergencyEventManageId,
        id: id ?? this.id,
        saasId: saasId ?? this.saasId,
        tenantId: tenantId ?? this.tenantId,
        updatedBy: updatedBy ?? this.updatedBy,
        updatedDate: updatedDate ?? this.updatedDate,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['branchId'] = branchId;
    map['createdBy'] = createdBy;
    map['createdDate'] = createdDate;
    map['deleteStatus'] = deleteStatus;
    map['detail'] = detail;
    map['emergencyEventManageId'] = emergencyEventManageId;
    map['commonAttaches'] = commonAttaches?.map((e) => e.toJson()).toList();
    map['id'] = id;
    map['saasId'] = saasId;
    map['tenantId'] = tenantId;
    map['updatedBy'] = updatedBy;
    map['updatedDate'] = updatedDate;
    return map;
  }
}

/// attatchIds : "[4760515434737664, 4770458824847360]"
/// branchId : 6627
/// createdBy : "8952"
/// createdDate : "2023-12-15 14:45:42"
/// deleteStatus : 0
/// detail : "xxxxxx"
/// emergencyEventManageId : 4780191922745344
/// handleTime : "2023-12-15 00:00:00"
/// id : 4780196538396672
/// saasId : 1000
/// tenantId : 1000
/// updatedBy : "8952"
/// updatedDate : "2023-12-15 14:45:42"

class EventHandleList {
  EventHandleList(
      {this.attatchIds,
      this.branchId,
      this.createdBy,
      this.createdDate,
      this.deleteStatus,
      this.detail,
      this.emergencyEventManageId,
      this.handleTime,
      this.id,
      this.saasId,
      this.tenantId,
      this.updatedBy,
      this.updatedDate,
      this.commonAttaches});

  EventHandleList.fromJson(dynamic json) {
    attatchIds = json['attatchIds'];
    branchId = json['branchId'];
    createdBy = json['createdBy'];
    createdDate = json['createdDate'];
    deleteStatus = json['deleteStatus'];
    detail = json['detail'];
    emergencyEventManageId = json['emergencyEventManageId'];
    commonAttaches = ((json['commonAttaches'] as List) ?? [])
        .map((e) => NetFileData.fromJson(e))
        .toList();
    handleTime = json['handleTime'];
    id = json['id'];
    saasId = json['saasId'];
    tenantId = json['tenantId'];
    updatedBy = json['updatedBy'];
    updatedDate = json['updatedDate'];
  }

  String? attatchIds;
  num? branchId;
  String? createdBy;
  String? createdDate;
  num? deleteStatus;
  String? detail;
  num? emergencyEventManageId;
  String? handleTime;
  num? id;
  num? saasId;
  num? tenantId;
  String? updatedBy;
  String? updatedDate;
  List<NetFileData>? commonAttaches;

  EventHandleList copyWith({
    String? attatchIds,
    num? branchId,
    String? createdBy,
    String? createdDate,
    num? deleteStatus,
    String? detail,
    num? emergencyEventManageId,
    String? handleTime,
    num? id,
    num? saasId,
    num? tenantId,
    String? updatedBy,
    String? updatedDate,
  }) =>
      EventHandleList(
        attatchIds: attatchIds ?? this.attatchIds,
        branchId: branchId ?? this.branchId,
        createdBy: createdBy ?? this.createdBy,
        createdDate: createdDate ?? this.createdDate,
        deleteStatus: deleteStatus ?? this.deleteStatus,
        detail: detail ?? this.detail,
        emergencyEventManageId:
            emergencyEventManageId ?? this.emergencyEventManageId,
        handleTime: handleTime ?? this.handleTime,
        id: id ?? this.id,
        saasId: saasId ?? this.saasId,
        tenantId: tenantId ?? this.tenantId,
        updatedBy: updatedBy ?? this.updatedBy,
        updatedDate: updatedDate ?? this.updatedDate,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['attatchIds'] = attatchIds;
    map['branchId'] = branchId;
    map['createdBy'] = createdBy;
    map['createdDate'] = createdDate;
    map['deleteStatus'] = deleteStatus;
    map['detail'] = detail;
    map['emergencyEventManageId'] = emergencyEventManageId;
    map['commonAttaches'] = commonAttaches?.map((e) => e.toJson()).toList();
    map['handleTime'] = handleTime;
    map['id'] = id;
    map['saasId'] = saasId;
    map['tenantId'] = tenantId;
    map['updatedBy'] = updatedBy;
    map['updatedDate'] = updatedDate;
    return map;
  }
}

/// attatchIds : "[4760515434737664, 4770458824847360]"
/// branchId : 6627
/// createdBy : "8952"
/// createdDate : "2023-12-15 14:47:25"
/// deleteStatus : 0
/// detail : "xxxxxx"
/// emergencyEventManageId : 4780191922745344
/// endFollow : false
/// handleTime : "2023-12-15 00:00:00"
/// id : 4780198230372352
/// saasId : 1000
/// tenantId : 1000
/// updatedBy : "8952"
/// updatedDate : "2023-12-15 14:47:25"

class EventFollowList {
  EventFollowList(
      {this.attatchIds,
      this.branchId,
      this.createdBy,
      this.createdDate,
      this.deleteStatus,
      this.detail,
      this.emergencyEventManageId,
      this.endFollow,
      this.handleTime,
      this.id,
      this.saasId,
      this.tenantId,
      this.updatedBy,
      this.updatedDate,
      this.commonAttaches});

  EventFollowList.fromJson(dynamic json) {
    attatchIds = json['attatchIds'];
    branchId = json['branchId'];
    createdBy = json['createdBy'];
    createdDate = json['createdDate'];
    deleteStatus = json['deleteStatus'];
    detail = json['detail'];
    commonAttaches = ((json['commonAttaches'] as List) ?? [])
        .map((e) => NetFileData.fromJson(e))
        .toList();
    emergencyEventManageId = json['emergencyEventManageId'];
    endFollow = json['endFollow'];
    handleTime = json['handleTime'];
    id = json['id'];
    saasId = json['saasId'];
    tenantId = json['tenantId'];
    updatedBy = json['updatedBy'];
    updatedDate = json['updatedDate'];
  }

  String? attatchIds;
  num? branchId;
  String? createdBy;
  String? createdDate;
  num? deleteStatus;
  String? detail;
  num? emergencyEventManageId;
  bool? endFollow;
  String? handleTime;
  num? id;
  num? saasId;
  num? tenantId;
  String? updatedBy;
  String? updatedDate;
  List<NetFileData>? commonAttaches;

  EventFollowList copyWith({
    String? attatchIds,
    num? branchId,
    String? createdBy,
    String? createdDate,
    num? deleteStatus,
    String? detail,
    num? emergencyEventManageId,
    bool? endFollow,
    String? handleTime,
    num? id,
    num? saasId,
    num? tenantId,
    String? updatedBy,
    String? updatedDate,
  }) =>
      EventFollowList(
        attatchIds: attatchIds ?? this.attatchIds,
        branchId: branchId ?? this.branchId,
        createdBy: createdBy ?? this.createdBy,
        createdDate: createdDate ?? this.createdDate,
        deleteStatus: deleteStatus ?? this.deleteStatus,
        detail: detail ?? this.detail,
        emergencyEventManageId:
            emergencyEventManageId ?? this.emergencyEventManageId,
        endFollow: endFollow ?? this.endFollow,
        handleTime: handleTime ?? this.handleTime,
        id: id ?? this.id,
        saasId: saasId ?? this.saasId,
        tenantId: tenantId ?? this.tenantId,
        updatedBy: updatedBy ?? this.updatedBy,
        updatedDate: updatedDate ?? this.updatedDate,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['attatchIds'] = attatchIds;
    map['branchId'] = branchId;
    map['createdBy'] = createdBy;
    map['createdDate'] = createdDate;
    map['deleteStatus'] = deleteStatus;
    map['detail'] = detail;
    map['emergencyEventManageId'] = emergencyEventManageId;
    map['commonAttaches'] = commonAttaches?.map((e) => e.toJson()).toList();
    map['endFollow'] = endFollow;
    map['handleTime'] = handleTime;
    map['id'] = id;
    map['saasId'] = saasId;
    map['tenantId'] = tenantId;
    map['updatedBy'] = updatedBy;
    map['updatedDate'] = updatedDate;
    return map;
  }
}
